local sz_huanyin_ex = fk.CreateSkill {
    name = "sz_huanyin_ex",
    tags = { Skill.Compulsory }
}

Fk:loadTranslationTable {
    ["sz_huanyin_ex"] = "幻瘾",
    [":sz_huanyin_ex"] = "锁定技，出牌阶段开始时，你失去0点体力，摸1张牌，结束阶段弃置所有牌，回复0点体力，每次发动技能时，所有数字+1，直到你死亡。",

}
sz_huanyin_ex:addEffect(fk.EventPhaseStart, {
    can_trigger = function(self, event, target, player, data)
        return target == player and player:hasSkill(sz_huanyin_ex.name) and player.phase == Player.Play
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local n = player:getMark("sz_huanyin_ex")
        if n > 0 then
            room:loseHp(player, n, sz_huanyin_ex.name)
        end
        player:drawCards(1 + n, sz_huanyin_ex.name)
        room:addPlayerMark(player, "sz_huanyin_ex")
    end,
})
sz_huanyin_ex:addEffect(fk.EventPhaseEnd, {
    can_trigger = function(self, event, target, player, data)
        return target == player and player:hasSkill(sz_huanyin_ex.name) and player.phase == Player.Finish
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local n = player:getMark("sz_huanyin_ex")
        if #player:getCardIds("he") > 0 then
            player:throwAllCards("he")
        end
        if n > 0 then
            room:recover {
                who = player,
                num = n,
                recoverBy = player,
                skillName = sz_huanyin_ex.name,
            }
        end
    end,
})

return sz_huanyin_ex
